home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGASIC / STRBASIC.LZH / LC.SB < prev    next >
Text File  |  1984-06-25  |  609b  |  26 lines

  1. 'A Simple Structured BASIC program to count the lines in an ASCII file.
  2.  
  3. procedure MAIN
  4.     on error goto CHECK.FOR.EOF
  5.  
  6.     input "File Name"; FILE.NAME$
  7.     open FILE.NAME$ for input as #1
  8.     LINE.COUNT = 0 : DONE.SW = 0
  9.     repeat
  10.         line input #1, L$
  11.         LINE.COUNT = LINE.COUNT+1
  12.     until DONE.SW = 1
  13.     print "There are";LINE.COUNT-1;"lines in ";FILE.NAME$
  14. endproc
  15.  
  16. CHECK.FOR.EOF|
  17.     ERROR.CODE = ERR : ERROR.LINE = ERL
  18.     if ERROR.CODE = 62
  19.         DONE.SW = 1
  20.         resume next
  21.     else
  22.         print "BASIC error";ERROR.CODE;"at";ERROR.LINE
  23.         stop 'Immediately halt program
  24.     endif
  25. end
  26.